<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>PhotoSphereViewer - equirectangular video demo</title>

        <link rel="stylesheet" href="/dist/core/index.css" />
        <link rel="stylesheet" href="/dist/markers-plugin/index.css" />
        <link rel="stylesheet" href="/dist/settings-plugin/index.css" />
        <link rel="stylesheet" href="/dist/video-plugin/index.css" />
        <link rel="stylesheet" href="style.css" />
    </head>
    <body>
        <div id="photosphere"></div>

        <script type="importmap">
            {
                "imports": {
                    "three": "/node_modules/three/build/three.module.js",
                    "@photo-sphere-viewer/core": "/dist/core/index.module.js",
                    "@photo-sphere-viewer/equirectangular-video-adapter": "/dist/equirectangular-video-adapter/index.module.js",
                    "@photo-sphere-viewer/autorotate-plugin": "/dist/autorotate-plugin/index.module.js",
                    "@photo-sphere-viewer/markers-plugin": "/dist/markers-plugin/index.module.js",
                    "@photo-sphere-viewer/resolution-plugin": "/dist/resolution-plugin/index.module.js",
                    "@photo-sphere-viewer/settings-plugin": "/dist/settings-plugin/index.module.js",
                    "@photo-sphere-viewer/video-plugin": "/dist/video-plugin/index.module.js"
                }
            }
        </script>

        <script type="module">
            import { Viewer } from '@photo-sphere-viewer/core';
            import { EquirectangularVideoAdapter } from '@photo-sphere-viewer/equirectangular-video-adapter';
            import { AutorotatePlugin } from '@photo-sphere-viewer/autorotate-plugin';
            import { MarkersPlugin } from '@photo-sphere-viewer/markers-plugin';
            import { ResolutionPlugin } from '@photo-sphere-viewer/resolution-plugin';
            import { SettingsPlugin } from '@photo-sphere-viewer/settings-plugin';
            import { VideoPlugin } from '@photo-sphere-viewer/video-plugin';

            const baseUrl = 'https://photo-sphere-viewer-data.netlify.app/assets/';

            const viewer = new Viewer({
                container: 'photosphere',
                adapter: EquirectangularVideoAdapter.withConfig({
                    autoplay: false,
                    muted: true,
                }),
                caption: 'Ayutthaya <b>&copy; meetle</b>',
                loadingImg: baseUrl + 'loader.gif',
                navbar: 'autorotate video zoom move caption settings fullscreen',
                plugins: [
                    VideoPlugin.withConfig({
                        progressbar: true,
                        bigbutton: true,
                        keypoints: [
                            { time: 0, position: { yaw: 0, pitch: 0 } },
                            { time: 5, position: { yaw: -Math.PI / 4, pitch: Math.PI / 8 } },
                            { time: 10, position: { yaw: -Math.PI / 2, pitch: 0 } },
                            { time: 15, position: { yaw: (-3 * Math.PI) / 4, pitch: -Math.PI / 8 } },
                            { time: 20, position: { yaw: -Math.PI, pitch: 0 } },
                            { time: 25, position: { yaw: (-5 * Math.PI) / 4, pitch: Math.PI / 8 } },
                            { time: 30, position: { yaw: (-3 * Math.PI) / 2, pitch: 0 } },
                            { time: 35, position: { yaw: (-7 * Math.PI) / 4, pitch: -Math.PI / 8 } },
                        ],
                    }),
                    AutorotatePlugin,
                    MarkersPlugin,
                    SettingsPlugin,
                    ResolutionPlugin.withConfig({
                        defaultResolution: 'FHD',
                        resolutions: [
                            {
                                id: 'UHD',
                                label: 'Ultra high',
                                panorama: { source: baseUrl + 'equirectangular-video/Ayutthaya_UHD.mp4' },
                            },
                            {
                                id: 'FHD',
                                label: 'High',
                                panorama: { source: baseUrl + 'equirectangular-video/Ayutthaya_FHD.mp4' },
                            },
                            {
                                id: 'HD',
                                label: 'Standard',
                                panorama: { source: baseUrl + 'equirectangular-video/Ayutthaya_HD.mp4' },
                            },
                            {
                                id: 'SD',
                                label: 'Low',
                                panorama: { source: baseUrl + 'equirectangular-video/Ayutthaya_SD.mp4' },
                            },
                        ],
                    }),
                ],
            });

            window.viewer = viewer;
        </script>
    </body>
</html>
